﻿import { NgModule } from '@angular/core';
import { NavigationEnd, Router, RouterModule } from '@angular/router';
import { PrinterComponent } from './printer/printer.component';
import { SettingComponent } from './setting/setting.component';
import { EquipmentComponent } from './equipment/equipment.component';
import { OrderComponent } from './order/order.component';

@NgModule({
    imports: [
        RouterModule.forChild([
            {
                path: '',
                children: [
                    { path: 'printer', component: PrinterComponent, data: { permission: 'Pages.Administration.OrganizationUnits' } },
                    { path: 'setting', component: SettingComponent, data: { permission: 'Pages.Administration.OrganizationUnits' } },
                    { path: 'equipment', component: EquipmentComponent, data: { permission: 'Pages.Administration.OrganizationUnits' } },
                    { path: 'order', component: OrderComponent, data: { permission: 'Pages.Administration.OrganizationUnits' } },
                ]
            }
        ])
    ],
    exports: [
        RouterModule
    ]
})
export class OutsourceRoutingModule {
    constructor(
        private router: Router
    ) {
        router.events.subscribe((event) => {
            if (event instanceof NavigationEnd) {
                window.scroll(0, 0);
            }
        });
    }
}
